package cn.cjxy.stf.springboot_thymeleaf.controller;

import cn.cjxy.stf.springboot_thymeleaf.domain.Country;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class Demo1Controller {

    @GetMapping("/demo01")
    public ModelAndView demo01() {//ModelAndView模型和视图
        //创建模型和视图对象
        ModelAndView mv = new ModelAndView();
        //跳转到test1.html
        mv.setViewName("test1");//classpath:/templates/test1.html
        //传递模型
        mv.addObject("country",new Country("中国","北京","亚洲"));
        return mv;
    }
}
